package com.mi.global.shop.common.utils;

import android.annotation.TargetApi;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.support.v7.app.NotificationCompat;
import android.widget.RemoteViews;

import com.mi.global.shop.R;


/**
 * Created by laihengyu on 2017/11/15.
 */

public class NotificationUtil {
    private static int notificationID = -1;

    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    public static void sendNotification(Context context, int icon, CharSequence title, CharSequence content,
                                                       PendingIntent pIntent) {
        // 创建 Notification
        NotificationManager nManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        Notification notification = new NotificationCompat.Builder(context)
                .setSmallIcon(R.drawable.icon_logo)// status bar icon
                .setLargeIcon(BitmapFactory.decodeResource(context.getResources(), icon))
                .setContentTitle(title)
                .setContentText(content)
                .setContentIntent(pIntent)
                .setFullScreenIntent(null, false)// 浮动通知
//                .setVisibility(Notification.VISIBILITY_PUBLIC)// 锁屏通知
                .setAutoCancel(true)
                .setWhen(System.currentTimeMillis())
                .build();
        // 将Notification发给Manager
        nManager.notify(notificationID++, notification);
    }

}
